package com.lx.java8;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import java.util.stream.Collectors;


public class ForEachAndMap {
    List<Employee> elist = Arrays.asList(new Employee("aaa", 45, 8888.88), new Employee("aaa", 45, 8888.88),
            new Employee("aaa", 45, 8888.88), new Employee("bbb", 32, 6666.66), new Employee("ccc", 47, 7777.77),
            new Employee("ddd", 89, 5555.55), new Employee("eee", 12, 9999.99));
    /**
     * @ClassName: ForEach
     * @param
     * @Return: void
     * @Decription: 全部执行
     * @CreateDate: Created in 2018/3/5 0005 下午 1:45
     * @Author: <a href="410508961@qq.com">夏凯</a>
     * @Modify:
     */
    @Test
    public void test1(){
        elist.stream().forEach(employee -> System.out.println(employee.getName()));
    }

    /**
     * @ClassName: ForEach
     * @param
     * @Return: void
     * @Decription: map的属性进行收集
     * @CreateDate: Created in 2018/3/5 0005 下午 1:47
     * @Author: <a href="410508961@qq.com">夏凯</a>
     * @Modify:
     */
    @Test
    public void test2(){
        List<String> collect = elist.stream().map(employee -> employee.getName()).collect(Collectors.toList());
        System.out.println(collect);
    }
}
